package main

import (
	"fmt"
	"strconv"
	"strings"
)

//作业5 连续多次输入半径并计算圆面积，输入特定符号后主动退出程序
func main() {
	var r string
	var R float64
	var err error
	num := 0
	var inits []string
	for {
		fmt.Printf("输入半径求面积,输入exit退出")
		fmt.Scan(&r)
		inits = append(inits, r)
		if strings.Contains(inits[num], "exit") {
			break
		}
		R, err = strconv.ParseFloat(inits[num], 64)
		if err != nil {
			fmt.Println("请输入正确的值")
		} else {
			fmt.Println(Sum(R))
		}
		num++
	}
}

func Sum(r float64) float64 {
	r = r * r
	const pi = 3.14
	sums := pi * r
	return sums
}
